//
//  OperationBillDiaoDuGoodInfoCell.m
//  LogisticsSupplier
//
//  Created by 吕晶 on 2021/7/28.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "OperationBillDiaoDuGoodInfoCell.h"

@interface OperationBillDiaoDuGoodInfoCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *xingLab;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UITextField *textField;
@property (nonatomic, strong) UILabel *lineLab;

@property (nonatomic, strong) UILabel *title1Lab;
@property (nonatomic, strong) UILabel *content1Lab;
@property (nonatomic, strong) UILabel *title2Lab;
@property (nonatomic, strong) UILabel *content2Lab;
@property (nonatomic, strong) UILabel *title3Lab;
@property (nonatomic, strong) UILabel *content3Lab;
@property (nonatomic, strong) UILabel *title4Lab;
@property (nonatomic, strong) UILabel *content4Lab;

@end

@implementation OperationBillDiaoDuGoodInfoCell

+ (instancetype)OperationBillDiaoDuGoodInfoCellWithTableView:(UITableView *)tableView {
    static NSString *cellID = @"OperationBillDiaoDuGoodInfoCell";
    OperationBillDiaoDuGoodInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[OperationBillDiaoDuGoodInfoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = Color_backgroundColor;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.bgView = [[UIView alloc] initWithFrame:CGRectMake(15, 0, ScreenW - 30, 130)];
        self.bgView.backgroundColor = HexColor(0xffffff);
        [self.contentView addSubview:self.bgView];
        
        self.lineLab = [[UILabel alloc] initWithFrame:CGRectMake(10, self.bgView.nim_height - 1, self.bgView.nim_width - 20, 1)];
        self.lineLab.backgroundColor = Color_backgroundColor;
        [self.bgView addSubview:self.lineLab];
        
        self.xingLab = [UILabel new];
        self.xingLab.text = @"*";
        self.xingLab.font = [UIFont systemFontOfSize:14];
        [self.xingLab sizeToFit];
        self.xingLab.nim_left = 10;
        self.xingLab.nim_top = 20;
        self.xingLab.textColor = HexColor(0xF35959);
        [self.bgView addSubview:self.xingLab];
        
        self.titleLab = [[UILabel alloc] initWithFrame:CGRectMake(self.xingLab.nim_right, 22.5, 120, 15)];
        self.titleLab.font = [UIFont systemFontOfSize:14];
        self.titleLab.textColor = HexColor(0x2B2C44);
        self.titleLab.text = @"装载信息";
        [self.bgView addSubview:self.titleLab];
        
        self.textField = [[UITextField alloc] initWithFrame:CGRectMake(self.titleLab.nim_right, 10, self.bgView.nim_width - 10 - self.titleLab.nim_right, 40)];
        self.textField.font = [UIFont systemFontOfSize:15];
        self.textField.textColor = HexColor(0x000000);
        self.textField.textAlignment = NSTextAlignmentRight;
        self.textField.placeholder = @"请输入";
        self.textField.userInteractionEnabled = NO;
        [self.bgView addSubview:self.textField];
        
        self.title1Lab = [UILabel new];
        self.title1Lab.textColor = HexColor(0x9C9DB3);
        self.title1Lab.font = [UIFont systemFontOfSize:14];
        self.title1Lab.text = @"货物件数：";
        [self.title1Lab sizeToFit];
        self.title1Lab.nim_left = self.titleLab.nim_left;
        self.title1Lab.nim_top = self.titleLab.nim_bottom + (self.bgView.nim_height - self.titleLab.nim_bottom - 10 - 2 * self.title1Lab.nim_height) * 0.5;
        [self.bgView addSubview:self.title1Lab];
        
        self.content1Lab = [UILabel new];
        self.content1Lab.textColor = HexColor(0x414141);
        self.content1Lab.font = [UIFont systemFontOfSize:14];
        self.content1Lab.nim_left = self.title1Lab.nim_right;
        self.content1Lab.nim_width = self.bgView.nim_width * 0.5 - self.content1Lab.nim_left;
        self.content1Lab.nim_height = self.title1Lab.nim_height;
        self.content1Lab.nim_top = self.title1Lab.nim_top;
        [self.bgView addSubview:self.content1Lab];
        
        self.title2Lab = [UILabel new];
        self.title2Lab.textColor = HexColor(0x9C9DB3);
        self.title2Lab.font = [UIFont systemFontOfSize:14];
        self.title2Lab.text = @"数量：";
        [self.title2Lab sizeToFit];
        self.title2Lab.nim_left = self.bgView.nim_width * 0.5;
        self.title2Lab.nim_top = self.title1Lab.nim_top;
        [self.bgView addSubview:self.title2Lab];
        
        self.content2Lab = [UILabel new];
        self.content2Lab.textColor = HexColor(0x414141);
        self.content2Lab.font = [UIFont systemFontOfSize:14];
        self.content2Lab.nim_left = self.title2Lab.nim_right;
        self.content2Lab.nim_width = self.bgView.nim_width - self.content2Lab.nim_left;
        self.content2Lab.nim_top = self.title2Lab.nim_top;
        self.content2Lab.nim_height = self.title2Lab.nim_height;
        [self.bgView addSubview:self.content2Lab];
        
        self.title3Lab = [UILabel new];
        self.title3Lab.textColor = HexColor(0x9C9DB3);
        self.title3Lab.font = [UIFont systemFontOfSize:14];
        self.title3Lab.text = @"货物重量：";
        [self.title3Lab sizeToFit];
        self.title3Lab.nim_left = self.titleLab.nim_left;
        self.title3Lab.nim_top = self.title1Lab.nim_bottom + 10;
        [self.bgView addSubview:self.title3Lab];
        
        self.content3Lab = [UILabel new];
        self.content3Lab.textColor = HexColor(0x414141);
        self.content3Lab.font = [UIFont systemFontOfSize:14];
        self.content3Lab.nim_left = self.title3Lab.nim_right;
        self.content3Lab.nim_width = self.bgView.nim_width * 0.5 - self.content3Lab.nim_left;
        self.content3Lab.nim_top = self.title3Lab.nim_top;
        self.content3Lab.nim_height = self.title3Lab.nim_height;
        [self.bgView addSubview:self.content3Lab];
        
        self.title4Lab = [UILabel new];
        self.title4Lab.textColor = HexColor(0x9C9DB3);
        self.title4Lab.font = [UIFont systemFontOfSize:14];
        self.title4Lab.text = @"货物体积：";
        [self.title4Lab sizeToFit];
        self.title4Lab.nim_left = self.bgView.nim_width * 0.5;
        self.title4Lab.nim_top = self.title3Lab.nim_top;
        [self.bgView addSubview:self.title4Lab];
        
        self.content4Lab = [UILabel new];
        self.content4Lab.textColor = HexColor(0x414141);
        self.content4Lab.font = [UIFont systemFontOfSize:14];
        self.content4Lab.nim_left = self.title4Lab.nim_right;
        self.content4Lab.nim_width = self.bgView.nim_width - self.content4Lab.nim_left;
        self.content4Lab.nim_top = self.title4Lab.nim_top;
        self.content4Lab.nim_height = self.title4Lab.nim_height;
        [self.bgView addSubview:self.content4Lab];
        
        self.height = self.bgView.nim_bottom;
    }
    return self;
}

-(void)setModel:(OperationBillDiaoDuModel *)model {
    _model = model;
    self.content1Lab.text = [NSString stringWithFormat:@"%d",model.goods_jnum];
    self.content2Lab.text = [NSString stringWithFormat:@"%d",model.goods_num];
    if (model.weight) {
        self.content3Lab.text = [NSString stringWithFormat:@"%@KG",[FactoryMethod removerNumberWithZero:[NSString stringWithFormat:@"%.2f",model.weight]]];
    }else {
        self.content3Lab.text = @"--KG";
    }
    if (model.volume) {
        self.content4Lab.text = [NSString stringWithFormat:@"%@m³",[FactoryMethod removerNumberWithZero:[NSString stringWithFormat:@"%.2f",model.volume]]];
    }else {
        self.content4Lab.text = @"--m³";
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
